package org.jeecg.modules.health_records.assess_special.controller;

import java.util.Arrays;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.health_records.assess_special.entity.AssessSpecialInfo;
import org.jeecg.modules.health_records.assess_special.service.IAssessSpecialInfoService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;


import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;


 /**
 * @Description: 全面评估的专科评估信息表
 * @Author: jeecg-boot
 * @Date:   2025-07-29
 * @Version: V1.0
 */
@Api(tags="全面评估的专科评估信息表")
@RestController
@RequestMapping("/assess_special/assessSpecialInfo")
@Slf4j
public class AssessSpecialInfoController extends JeecgController<AssessSpecialInfo, IAssessSpecialInfoService> {
	@Autowired
	private IAssessSpecialInfoService assessSpecialInfoService;
	
	/**
	 * 分页列表查询
	 *
	 * @param assessSpecialInfo
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "全面评估的专科评估信息表-分页列表查询")
	@ApiOperation(value="全面评估的专科评估信息表-分页列表查询", notes="全面评估的专科评估信息表-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<AssessSpecialInfo>> queryPageList(AssessSpecialInfo assessSpecialInfo,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<AssessSpecialInfo> queryWrapper = QueryGenerator.initQueryWrapper(assessSpecialInfo, req.getParameterMap());
		Page<AssessSpecialInfo> page = new Page<AssessSpecialInfo>(pageNo, pageSize);
		IPage<AssessSpecialInfo> pageList = assessSpecialInfoService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	
	/**
	 *   添加
	 *
	 * @param assessSpecialInfo
	 * @return
	 */
	@AutoLog(value = "全面评估的专科评估信息表-添加")
	@ApiOperation(value="全面评估的专科评估信息表-添加", notes="全面评估的专科评估信息表-添加")
	//@RequiresPermissions("assess_special:assess_special_info:add")
	@PostMapping(value = "/add")
	public Result<AssessSpecialInfo> add(@RequestBody AssessSpecialInfo assessSpecialInfo) {
		assessSpecialInfoService.save(assessSpecialInfo);
		return Result.OK("添加成功！",assessSpecialInfo);
	}
	
	/**
	 *  编辑
	 *
	 * @param assessSpecialInfo
	 * @return
	 */
	@AutoLog(value = "全面评估的专科评估信息表-编辑")
	@ApiOperation(value="全面评估的专科评估信息表-编辑", notes="全面评估的专科评估信息表-编辑")
	//@RequiresPermissions("assess_special:assess_special_info:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody AssessSpecialInfo assessSpecialInfo) {
		assessSpecialInfoService.updateById(assessSpecialInfo);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "全面评估的专科评估信息表-通过id删除")
	@ApiOperation(value="全面评估的专科评估信息表-通过id删除", notes="全面评估的专科评估信息表-通过id删除")
	//@RequiresPermissions("assess_special:assess_special_info:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		assessSpecialInfoService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "全面评估的专科评估信息表-批量删除")
	@ApiOperation(value="全面评估的专科评估信息表-批量删除", notes="全面评估的专科评估信息表-批量删除")
	//@RequiresPermissions("assess_special:assess_special_info:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.assessSpecialInfoService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "全面评估的专科评估信息表-通过id查询")
	@ApiOperation(value="全面评估的专科评估信息表-通过id查询", notes="全面评估的专科评估信息表-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<AssessSpecialInfo> queryById(@RequestParam(name="id",required=true) String id) {
		AssessSpecialInfo assessSpecialInfo = assessSpecialInfoService.getById(id);
		if(assessSpecialInfo==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(assessSpecialInfo);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param assessSpecialInfo
    */
    //@RequiresPermissions("assess_special:assess_special_info:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, AssessSpecialInfo assessSpecialInfo) {
        return super.exportXls(request, assessSpecialInfo, AssessSpecialInfo.class, "全面评估的专科评估信息表");
    }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("assess_special:assess_special_info:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, AssessSpecialInfo.class);
    }
	 @ApiOperation(value="全面评估的专科评估信息表-按其他条件查询", notes="全面评估的专科评估信息表-按其他条件查询")
	 @PostMapping(value = "/queryByOther")
	 public  Result<List<AssessSpecialInfo>> queryByOther(@RequestBody AssessSpecialInfo assessSpecialInfo) {
		 //判断查询参数是否为空
		 if((assessSpecialInfo.getName()==null||"".equals(assessSpecialInfo.getName()))
		 &&
			(assessSpecialInfo.getTel()==null||"".equals(assessSpecialInfo.getTel()))) {
			 return Result.error("请输入查询参数");
		 }else {
			 List<AssessSpecialInfo> list1 = assessSpecialInfoService.queryByOther(assessSpecialInfo);
			 return Result.OK(list1);
		 }
	 }

}
